// Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
//
// Licensed under the Mulan PSL v2.
// You can use this file according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of the License at
//
//     http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
// FOR MORE DETAILS.

#include "CaseDataEntryParserFactory.h"

#include <string>
using namespace SG::DBManager;
using namespace SG::DataStructure;
using namespace SG::Import::BDF;

CaseDataEntryParserFactory::CaseDataEntryParserFactory ()
{
    m_NEParseFunMap.clear ();
}

CaseDataEntryParserFactory* CaseDataEntryParserFactory::GetInstance ()
{
    static CaseDataEntryParserFactory instance;
    return &instance;
}

//
bool CaseDataEntryParserFactory::Register (const std::string& EntryType, NEParseFunP NastranParseSP)
{
    m_NEParseFunMap[EntryType] = NastranParseSP;
    return true;
}
void CaseDataEntryParserFactory::Unregister (const std::string& EntryType)
{
    m_NEParseFunMap.erase (EntryType);
}

void CaseDataEntryParserFactory::UnregisterAll ()
{
    m_NEParseFunMap.clear ();
}

void CaseDataEntryParserFactory::ClearField ()
{
    m_SolutionSequences = 0;
    m_FirstSubcaseID    = 0;
}

CaseDataEntryParserFactory::NEParseFunP CaseDataEntryParserFactory::GetFunction (const std::string& EntryType)
{
    auto it = m_NEParseFunMap.find (EntryType);
    if (it != m_NEParseFunMap.end ())
    {
        return it->second;
    }
    return nullptr;
}
